package com.cmo.rzl.qmj;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.beetl.sql.core.kit.StringKit;

import com.cmo.rzl.core.base.BaseController;
import com.cmo.rzl.core.jfinal.ext.autoroute.ControllerBind;
import com.cmo.rzl.core.toolbox.Record;
import com.cmo.rzl.core.toolbox.kit.ShardKit;
import com.cmo.rzl.shine.service.PatientQueueService;
import com.cmo.rzl.shine.service.impl.PatientQueueServiceImpl;

@ControllerBind(controllerKey="/qmj")
public class QmjController extends BaseController {

	PatientQueueService patientqueue=new PatientQueueServiceImpl();
	ShardKit shared=new ShardKit();
	
	public void list_content_patient(){
		Map<String, Object> map=new HashMap<String, Object>();
 		List<Record> list=patientqueue.list_content_patient(shared.getIpAddr(getRequest()));
		if(list.size()<0){
			map.put("return_code", "fail");
			map.put("return_msg", "查询失败");
			renderJson(map);
			return;
		}else{
			map.put("return_code", "success");
			map.put("return_msg", "查询成功");
			map.put("count", list.size());
			map.put("list", list);
			patientqueue.update_istype();
			renderJson(map);
		}
		
		renderJson(map);
	}
	
	public void update_content(){
		Map<String, Object> map=new HashMap<String, Object>();
		String queue_type_id=getPara("queue_type_id");
		if(StringKit.isBlank(queue_type_id)){
			map.put("return_code", "fail");
			map.put("return_msg", "不能为空值");
			renderJson(map);
			return;
		}
		String id =getPara("id");
		if(StringKit.isBlank(id)){
			map.put("return_code", "fail");
			map.put("return_msg", "不能为空值");
			renderJson(map);
			return;
		}
		int update_content= patientqueue.update_content(Integer.parseInt(queue_type_id), Integer.parseInt(id),shared.getIpAddr(getRequest()));
		if(update_content<0){
			map.put("return_code", "fail");
			map.put("return_msg", "更改失败");
			renderJson(map);
			return;
		}else{
			map.put("return_code", "success");
			map.put("return_msg", "更改成功");
			renderJson(map);
		}
		renderJson(map);
	}
}
